﻿using MessageBoxNS;
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using UnityEngine;
using UnityEngine.UI;

/**
 *Copyright(C) 2019 by 殊未
 *All rights reserved.
 *FileName:     
 *Author:      丁冉
 *Version:      BVP3.0
 *UnityVersion:    2018.4.0
 *Date:         #DATE#
 *Description:   
 *History:
*/

public class SelectInciseType : MonoBehaviour
{
    public UIController uIController;
    public Dropdown SelectInciseDropDown;

    public Dropdown SelectTabName;
    private void Start()
    {
        SelectInciseDropDown.options = AddDropDownOptionsState();
        SelectInciseDropDown.onValueChanged.AddListener(SelectInciseDropDownValueChange);

        SetTabNameDropDown();
        SelectTabName.onValueChanged.AddListener(SelectTabNameDropDownValueChange);
    }

    private void SelectTabNameDropDownValueChange(int arg0)
    {
        uIController.SelectTabName = SelectTabName.options[arg0].text;
    }

    private void SelectInciseDropDownValueChange(int state)
    {
        uIController.ESelectInciseType = (EIncise)state;
    }

    private List<Dropdown.OptionData> AddDropDownOptionsState()
    {
        List<Dropdown.OptionData> temp = new List<Dropdown.OptionData>();

        string[] tempStr = Enum.GetNames(typeof(EIncise));

        List<string> list = tempStr.ToList();

        for (int i = 0; i < list.Count; i++)
        {
            temp.Add(new Dropdown.OptionData(list[i]));
        }
        return temp;
    }

    public void SetTabNameDropDown()
    {
        List<Dropdown.OptionData> temp = new List<Dropdown.OptionData>();
        Dictionary<string, ExcelData> tempData = uIController.GetData();
        foreach (var item in tempData.Keys)
        {
            temp.Add(new Dropdown.OptionData(item));
        }
        SelectTabName.options = temp;
        if (SelectTabName.options.Count > 0)
            uIController.SelectTabName = SelectTabName.options[0].text;
    }
}
